package com.isoft.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * Created by yigeyanse on 2017/8/16.
 */
@Data
@Entity
@Table(name = "sys_permission")
public class SysPermission implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy= GenerationType.AUTO)
	private Integer sysPermissionId;

	@Column
	private Integer pId;

	@Column
	private String sysPermissionName;

	@Column(columnDefinition = "enum('function','business','owner')")
	private String sysPermissionType;

	@Column
	private String sysPermissionDesc; // 密码;

	@Column
	private Boolean available = Boolean.FALSE; // 是否可用,如果不可用将不会添加给用户
	
	@ManyToMany
    @JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="permissionId")},inverseJoinColumns={@JoinColumn(name="roleId")})
    private List<SysRole> roles;

	@Override
	public String toString() {
		return "SysPermission [sysPermissionId=" + sysPermissionId + ", pId=" + pId + ", sysPermissionName=" + sysPermissionName + ", sysPermissionType=" + sysPermissionType + ", sysPermissionDesc=" + sysPermissionDesc
				+ ", available=" + available + "]";
	}

}